package edit;

import org.jbox2d.common.Vec2;

import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.RoundRectangle2D;

/**
 * @author will
 * @date Aug 10, 2008 5:27:43 PM
 */
public class RoundRectangleContext extends DrawShapeContext {
    public static final float arcw= 0.5f;
        public Shape createShape() {
            return new RoundRectangle2D.Float();
        }

        public Shape setShape(Vec2 start, Vec2 now) {
            RoundRectangle2D.Float aFloat = (RoundRectangle2D.Float) shape;
            Vec2 first=Vec2.min(start,now);
            Vec2 dist = start.sub(now).abs();
            aFloat.setRoundRect(first.x,first.y,dist.x,dist.y,arcw*dist.x,arcw*dist.y);
            return aFloat;
        }
}
